from  time import sleep
from selenium import webdriver
from selenium.webdriver.edge.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
from lxml import etree

service = Service()
service.path = r'chromedriver.exe'
# 启动浏览器
browser = webdriver.Chrome(service=service)

# 让浏览器发起一个指定url对应请求
browser.get('https://www.runoob.com/try/try.php?filename=jqueryui-api-droppable')

# 如果定位的标签是存在于iframe标签之中则必须通过以下操作进行标签定位
browser.switch_to.frame('iframeResult') # 切换浏览器标签定位的作作用域
div = browser.find_element(By.ID,'draggable')

# 点击+划动
# 动作链
action = ActionChains(browser)

#点击长按指定的标签
action.click_and_hold(div)

for i in range(5):
    # perform 立即执行动作链
    # move_by_offset(x,y) x水平,y垂直
    action.move_by_offset(17,0).perform()
    sleep(0.3)

# 释放动作链
action.release()
browser.quit()
sleep(5)